<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="include.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="head.jsp" %>
<title><spring:message code="title.signUpUser" /></title>
</head>
 
<body>
	<%@ include file="header.jsp" %>
	<div class="container-fluid">
		<div class="page-header">
			<h2>Customer SignUp Form - JSR303 @Valid example</h2>	
			<h3>Xin chào các bạn ưu tú</h3>	
		</div>
		<form:form method="POST" cssClass="form-horizontal" commandName="user" action="${pageContext.request.contextPath}/user/add">
			<form:errors path="*" cssClass="alert alert-error"  element="div" />
			<div class="control-group">
				<label class="control-label"><spring:message code="label.username" /></label>
				<div class="controls">
					<form:input path="username"/>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><spring:message code="label.password" /></label>
				<div class="controls">
					<form:password path="password"/>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><spring:message code="label.email" /></label>
				<div class="controls">
					<form:input path="email"/>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><spring:message code="label.firstName" /></label>
				<div class="controls">
					<form:input path="firstName"/>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><spring:message code="label.lastName" /></label>
				<div class="controls">
					<form:input path="lastName"/>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><spring:message code="label.phoneNumber" /></label>
				<div class="controls">
					<form:input path="phoneNumber"/>
				</div>
			</div>
			<div class="control-group">
				<div class="controls">
					<input class="btn" type="submit" value="<spring:message code="button.user.signUp" />" />
				</div>
			</div>
		</form:form>
		<hr />
		<table class="table table-bordered">
			<thead>
				<tr>
					<td><spring:message code="label.username" /></td>
					<td>Name</td>
					<td><spring:message code="label.email"/></td>
					<td>&nbsp;</td>
				</tr>
			</thead>
			<c:if  test="${!empty listUser}">
			<tbody>
				<c:forEach items="${listUser}" var="user">
				<tr>
					<td>${user.username}</td>
					<td>${user.firstName}, ${user.lastName}</td>
					<td>${user.email}</td>		
					<td>
						<a class="btn btn-mini" href="${pageContext.request.contextPath}/user/edit/${user.id }"><i class="icon-edit"></i> <spring:message code="button.edit"></spring:message> </a>
						<a class="btn btn-mini btn-danger" href="${pageContext.request.contextPath}/user/delete/${user.id }"><i class="icon-remove icon-white"></i> <spring:message code="button.delete"></spring:message> </a>
					</td>
				</tr>		
				</c:forEach>
			</tbody>
			</c:if>
		</table>
	</div>
	<%@ include file="footer.jsp" %>
</body>
</html>